package com.cw1.factory.simpleFactory.pizzastore.factroy;

import com.cw1.factory.simpleFactory.pizzastore.constant.PizzaConstant;
import com.cw1.factory.simpleFactory.pizzastore.pizza.ChessPizza;
import com.cw1.factory.simpleFactory.pizzastore.pizza.GreekPizza;
import com.cw1.factory.simpleFactory.pizzastore.pizza.PepperPizza;
import com.cw1.factory.simpleFactory.pizzastore.pizza.Pizza;

/**
 * @Author qiuMi
 * @description 披萨 - 简单工厂
 * @Date 2022-09-29 22:02
 **/
public class SimpleFactory {
    public Pizza createPizza(String orderType) {
        System.out.println("使用简单工厂模式");
        Pizza pizza = null;
        if (PizzaConstant.GREEK.equals(orderType)) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if (PizzaConstant.CHESS.equals(orderType)) {
            pizza = new ChessPizza();
            pizza.setName("切丝披萨");
        } else if (PizzaConstant.PEPPER.equals(orderType)) {
            pizza = new PepperPizza();
            pizza.setName("胡椒披萨");
        }
        return pizza;
    }

    public static Pizza createPizza2(String orderType) {
        System.out.println("使用简单工厂模式");
        Pizza pizza = null;
        if (PizzaConstant.GREEK.equals(orderType)) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if (PizzaConstant.CHESS.equals(orderType)) {
            pizza = new ChessPizza();
            pizza.setName("切丝披萨");
        } else if (PizzaConstant.PEPPER.equals(orderType)) {
            pizza = new PepperPizza();
            pizza.setName("胡椒披萨");
        }
        return pizza;
    }
}
